import type {
  AiEvaluationResponse,
  ApplicationDetailResponse,
  ApplicationOptionsResponse,
  ApplicationPageForTeacherResponse,
  ApplicationTeacherPageQuery,
  ReviewApplicationRequest,
  ReviewApplicationResponseWrapper
} from "./type"
import { request } from "@/http/axios"

/**
 * 老师分页获取职位申请列表
 * @param query 分页查询参数
 * @returns 分页结果
 */
export function getApplicationListApi(
  query: ApplicationTeacherPageQuery
) {
  return request<ApplicationPageForTeacherResponse>({
    url: "/position/application/teacher/position/page",
    method: "post",
    data: query
  })
}

/**
 * 获取申请选项
 * @returns 申请选项（状态等）
 */
export function getApplicationOptionsApi() {
  return request<ApplicationOptionsResponse>({
    url: "/position/application/options",
    method: "get"
  })
}

/**
 * 审核申请
 * @param data 审核数据
 * @returns 审核结果
 */
export function reviewApplicationApi(data: ReviewApplicationRequest) {
  return request<ReviewApplicationResponseWrapper>({
    url: "/position/application/teacher/review",
    method: "put",
    data
  })
}

/**
 * 获取申请详情
 * @param applicationId 申请ID
 * @returns 申请详情
 */
export function getApplicationDetailApi(applicationId: number) {
  return request<ApplicationDetailResponse>({
    url: `/position/application/teacher/detail/${applicationId}`,
    method: "get"
  })
}

/**
 * 评估简历
 * @param applicationId 申请ID
 * @returns 评估结果
 */
export function evaluateApplicationApi(applicationId: number) {
  return request<AiEvaluationResponse>({
    url: `/ai/evaluate/application`,
    method: "get",
    params: {
      applicationId
    },
    // 20秒超时
    timeout: 20000
  })
}
